package cn.structure.ipc;

import cn.structure.edp.AbstractInterface;
import cn.structure.edp.Inheritance;

import java.util.Objects;

public class FulfillMethod extends IpcEntity {
    private AbstractInterface abstractInterface;
    private Inheritance inheritance;

    public FulfillMethod(AbstractInterface abstractInterface, Inheritance inheritance) {
        super();
        this.abstractInterface = abstractInterface;
        this.inheritance = inheritance;
    }

    public enum Role {
        abstractInterface, inheritance
    }

    public AbstractInterface getAbstractInterface() {
        return abstractInterface;
    }

    public void setAbstractInterface(AbstractInterface abstractInterface) {
        this.abstractInterface = abstractInterface;
    }

    public Inheritance getInheritance() {
        return inheritance;
    }

    public void setInheritance(Inheritance inheritance) {
        this.inheritance = inheritance;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("FulfillMethod{\n\t");
        sb.append(super.toString());
        sb.append("\n\t\"abstractInterface\":")
                .append(abstractInterface);
        sb.append(",\n\t\"inheritance\":")
                .append(inheritance);
        sb.append("\n}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        FulfillMethod that = (FulfillMethod) o;
        return Objects.equals(abstractInterface, that.abstractInterface) &&
                Objects.equals(inheritance, that.inheritance);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), abstractInterface, inheritance);
    }
}
